def power(x,n = 2):  # 缺省参数，默认参数
    return x ** n
result1 = power(2,3)
print(result1)

result2 = power(2)
print(result2)

print("*" * 20)


def infos(name,age=24,gender='male'):
    return "大家好，我叫%s，我今年%d，我是一名%s" % (name,age,gender)

s = infos("jay")
jay = infos("jay",gender='female')
print(s)
print(jay)




def total(*args): # 可变参数
    print(args)
    result = 0
    for i in args:
        result += i
    return result

print(total(1,2,3,4,5))
print(total(1,2,3))

a = [1,2,3,4,5]
result = total(*a)
print("result=",result)


def f(**kwargs): # 可变参数，接收字典
    for k,v in kwargs.items():
        print(k,v)
d = {
   "name":"jay",
    "age":24,
}
f(**d)




